#include <irrlicht.h>
#include <IEventReceiver.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

class MyEventReceiver : public IEventReceiver
{
public:
  struct SMouseState
  {
    core::position2di Position;
    bool LeftButtonDown;
    bool RightButtonDown;
    bool MouseMoved;
    SMouseState() : LeftButtonDown(false), RightButtonDown(false), MouseMoved(false) { }
  } MouseState;

  struct SKeyState
  {
    bool KeyIsDown;
    SKeyState() : KeyIsDown(false) { }
  } KeyState;

  virtual bool OnEvent(const SEvent& event)
  {
    if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
    {
      switch (event.MouseInput.Event)
      {
      case EMIE_LMOUSE_PRESSED_DOWN:
        MouseState.LeftButtonDown = true;
        break;

      case EMIE_RMOUSE_PRESSED_DOWN:
        MouseState.RightButtonDown = true;
        break;

      //case EMIE_MOUSE_MOVED:
      //  //MouseState.MouseMoved = true;
      //  //if (event.MouseInput.Event != EMIE_MOUSE_MOVED)
      //    MouseState.MouseMoved = true;
      //  break;

      /*case EMIE_MOUSE_MOVED:
        MouseState.Position.X = event.MouseInput.X;
        MouseState.Position.Y = event.MouseInput.Y;
        break;*/

      default:
        // We won't use the wheel
        break;
      }
    }

    if (event.EventType == irr::EET_KEY_INPUT_EVENT)
      if (event.KeyInput.PressedDown)
        KeyState.KeyIsDown = true;

    return true;
  }

  const SMouseState & GetMouseState(void) const
  {
    return MouseState;
  }

  MyEventReceiver()
  {
  }
private:

};